//
//  GGBannerCollectionViewCell.m
//  GGBannerViewDemo
//
//  Created by GuinsooMBP on 15/10/16.
//  Copyright (c) 2015年 gaonan. All rights reserved.
//

#import "GGBannerCollectionViewCell.h"

@implementation GGBannerCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.imageView = [[UIImageView alloc]init];
        self.imageView.translatesAutoresizingMaskIntoConstraints = NO;
        [self.contentView addSubview:self.imageView];
        [self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[_imageView]-0-|" options:0 metrics:0 views:NSDictionaryOfVariableBindings(_imageView)]];
        [self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[_imageView]-0-|" options:0 metrics:0 views:NSDictionaryOfVariableBindings(_imageView)]];
        
        self.cameraBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        self.cameraBtn.translatesAutoresizingMaskIntoConstraints = NO;
        self.cameraBtn.hidden = YES;
        [self.cameraBtn setImage:[UIImage imageNamed:@"AuCh_camera68"] forState:UIControlStateNormal];
        [self.cameraBtn addTarget:self action:@selector(cameraBtnTapped:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:self.cameraBtn];
        [self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:[_cameraBtn(==68)]-10-|" options:0 metrics:0 views:NSDictionaryOfVariableBindings(_cameraBtn)]];
        [self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[_cameraBtn(==48)]-10-|" options:0 metrics:0 views:NSDictionaryOfVariableBindings(_cameraBtn)]];
    }
    return self;
}

- (void)cameraBtnTapped:(UIButton *)btn {
    if ([self.delegate respondsToSelector:@selector(GGBannerCollectionViewCell:cameraBtnTapped:)]) {
        [self.delegate GGBannerCollectionViewCell:self cameraBtnTapped:btn];
    }
}

@end
